package com.example.rent.mapper.yx;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.rent.entity.House;
import com.example.rent.entity.Houseowner;
import com.example.rent.entity.Meeting;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wanted
 * @since 2021-12-02
 */
@Repository
public interface HouseownerMapper extends BaseMapper<Houseowner> {
    @Select("select * from house where house.hphone = #{id} ")
    List<House> showMyHouse(long id);

    @Update("update houseowner set password = #{pwd} where hphone = #{id}")
    int changePwd(long id,String pwd);

    @Update("update houseowner set housename = #{myName},address = #{address},freetime = #{freetime} where hphone = #{id}")
    int updateMyInfo(long id,String myName,String address,String freetime);

    @Select("select * from meeting where meeting.hphone = #{id}")
    List<Meeting> getMessage(long id);

    @Select("select address from house where houseid = #{houseid}")
    String getHouseAddress(int houseid);

    @Update("update house set state = #{state} where address = #{address}")
    int updateHouseState(String address,int state);

    @Select("select houseid from house where address = #{address}")
    int getHouseId(String address);

    @Insert("insert into house(type,livenum,rent,address,state,hphone) values (#{type},#{livenum},#{rent},#{address},#{state},#{id})")
    int insertMyHouseInfo(long id,int type,int livenum,float rent,String address,int state);

    @Insert("REPLACE INTO repair(houseid,description) VALUES (#{houseid},#{description})")
    int insertRepair(int houseid,String description);

    @Delete("delete from house where hphone = #{id} and address = #{address} and livenum = #{livenum}")
    int deleteThisHouse(long id,String address,int livenum);
}
